package leetcode.weekly.week313;

//Solution2Test
public class Solution2 {
	public int maxSum(int[][] grid) {
		int m = grid.length, n = grid[0].length;
		int ans = Integer.MIN_VALUE;
		for (int i = 1; i < m - 1; i++) {
			for (int j = 1; j < n - 1; j++) {
				int cur = grid[i][j] + grid[i - 1][j - 1] + grid[i - 1][j] + grid[i - 1][j + 1] + grid[i + 1][j - 1]
						+ grid[i + 1][j] + grid[i + 1][j + 1];
				ans = Math.max(ans, cur);
			}
		}
		return ans;
	}

}
